package com.hairline.hairlinemarket.controller;

import com.github.pagehelper.PageInfo;
import com.hairline.hairlinemarket.bean.common.BaseRespVo;
import com.hairline.hairlinemarket.bean.vo.CollInfo;
import com.hairline.hairlinemarket.service.CollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * Author:杨小凯
 * Date:2023-04-23 20:40
 * Description:<描述>
 */
@RestController
@RequestMapping("/collect")
public class CollectController {

    @Autowired
    private CollectService collectService;

    @RequestMapping("/addordelete")
    public BaseRespVo addordelete(@RequestBody Map map){

        // 收藏
        collectService.addCollect(map);

        return BaseRespVo.ok();
    }

    @RequestMapping("/list")
    public BaseRespVo list(byte type,Integer page,Integer limit){

        // 展示收藏
        PageInfo<CollInfo> pageInfo = collectService.showCollects(type, page, limit);
        /*if (pageInfo==null){
            return BaseRespVo.fail("没有收藏")
        }*/
        return BaseRespVo.ok(pageInfo);
    }
}
